package com.rainng.coursesystem.service.leader;

import com.rainng.coursesystem.manager.leader.EventManager;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.model.vo.response.table.LeaderEventItemVO;
import com.rainng.coursesystem.service.BaseService;
import com.rainng.coursesystem.util.LessonTimeConverter;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("leader_eventService")
public class EventService1 extends BaseService {
    private final EventManager manager;
    private final LessonTimeConverter lessonTimeConverter;

    public EventService1(EventManager manager, LessonTimeConverter lessonTimeConverter) {
        this.manager = manager;
        this.lessonTimeConverter = lessonTimeConverter;
    }

    public ResultVO list() {
        Integer leaderId = getUserId();

        List<LeaderEventItemVO> list = manager.listLeaderEvent(leaderId);
        for (LeaderEventItemVO vo : list) {
            vo.setTime(lessonTimeConverter.covertTimePart(vo.getTime()));
        }

        return result(list);
    }
}
